#include "Globals.h"
#include "Logger.h"
#include "EngineCore.h"

//if on MS VS include the memory profiler
#ifdef _MSC_VER
//#include <vld.h>
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#else
#include <auto_ptr.h>
#endif
//The entry point of the program

int main(int argc, char* args[])
{
    LOGNOTE << "Engine started. " << "Build date : " << BUILD_TIME;

    Globals* glob = Globals::GetInstance( );

    glob->Initialization( true, "main.xml" );
    
    EngineCore game;

    int result;
    
    if( game.Init( glob->GetScreenWidth( ), glob->GetScreenHeight( ), 32, glob->GetFullscreen( ) ) )
    {
        result = game.Run( );
    }
    else
    {
        result = -1;
        LOG( Logger::CHANNEL_LOADING, LogFileStream::LEVEL_ERROR ) << "Failed to initialize engine.";
    }

    LOGNOTE << "Engine terminated.";
    
    Logger::DeleteInstance();
    return result;
}
